# https://gitee.com/yueyinqiu5990/tj12413601/blob/master/assignment1/question1/main_confidence_level.py
import torch


def _print_confidence_level(n, delta, p):
    n = torch.tensor(n, dtype=torch.float64)
    x = n * delta / torch.sqrt(2 * n * p * (1 - p))
    print(f"n={n}, delta={delta}, p={p}:")
    print(f"=erf({x})={torch.erf(x)}")
    print()


def _main():
    _print_confidence_level(655360, 1 / 100000, 1 / 3)
    _print_confidence_level(655360, 1 / 1000, 1 / 3)


if __name__ == "__main__":
    _main()
